<?php
// Tim'Roster
// Copyright (c) 2011 Nicolas Nallet <aspgic2@gmail.com>
//
// This file is part of Tim'Roster.
//
// Tim'Roster is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Tim'Roster is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

$xml_config = simplexml_load_file('config.xml');

include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/technical_class/language/language.php');
include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/class/Guild.php');
include_once ($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/web_ui/common_function.php');
require_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/external_libraries/ryzom_api/ryzom_api.php');


function render_guild_name_and_icon(Guild $guild){

    return '<table ><tr>'
          .'    <td>'.ryzom_guild_icon_image($guild->get_icon(), 's').'</td>'
          .'    <td><h1>'.$guild->get_name().'</h1></td>'
          .'</tr></table>';
}


function render_guild_general_information(Guild $guild){

    $column_array = array();
    $column_array[] = Language::get_instance()->get_label('lb_information');
    $column_array[] = Language::get_instance()->get_label('');

    $content = generate_html_table_header($column_array, 350, true);

    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_race'),$guild->get_race());
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_creation_date'), $guild->get_creation_date());
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_description'), $guild->get_description());
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_money'), number_format($guild->get_money(), 0, '.', ' '));
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_civilization'), $guild->get_civilization());
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_cult'), $guild->get_cult());

    $content .= generate_html_table_footer();

    return $content;
}

function render_guild_fame(Guild $guild){

    $column_array = array();
    $column_array[] = Language::get_instance()->get_label('lb_fame');
    $column_array[] = Language::get_instance()->get_label('');

    $faction_fame_table = generate_html_table_header($column_array, 250, true);


    $faction_fame_table .= generate_html_table_row(Language::get_instance()->get_label('lb_fyros'), $guild->get_fyros_fame());
    $faction_fame_table .= generate_html_table_row(Language::get_instance()->get_label('lb_matis'), $guild->get_matis_fame());
    $faction_fame_table .= generate_html_table_row(Language::get_instance()->get_label('lb_tryker'), $guild->get_tryker_fame());
    $faction_fame_table .= generate_html_table_row(Language::get_instance()->get_label('lb_zorai'), $guild->get_zorai_fame());
    $faction_fame_table .= generate_html_table_row(Language::get_instance()->get_label('lb_kami'), $guild->get_kami_fame());
    $faction_fame_table .= generate_html_table_row(Language::get_instance()->get_label('lb_karavan'), $guild->get_karavan_fame());


    $faction_fame_table .= generate_html_table_footer();

    return $faction_fame_table;
}

function render_guild_member_list(Guild $guild){

    $column_array = array();
    $column_array[] = Language::get_instance()->get_label('lb_member_statistics');
    $column_array[] = '';

    $content = generate_html_table_header($column_array, 300, true);

    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_member_count'), count($guild->get_member_list()));
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_leader'),$guild->get_grade_member_count(Guild_Member::GUILD_LEADER_GRADE_ID));
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_high_officer'),$guild->get_grade_member_count(Guild_Member::GUILD_HIGH_OFFICER_GRADE_ID));
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_officer'),$guild->get_grade_member_count(Guild_Member::GUILD_OFFICER_GRADE_ID));
    $content .= generate_html_table_row(Language::get_instance()->get_label('lb_member'),$guild->get_grade_member_count(Guild_Member::GUILD_MEMBER_GRADE_ID));
    $content .= generate_html_table_footer();

    return $content;
}



function render_guild_light(Guild $guild){
    return '<table><tr><td>'.ryzom_guild_icon_image($guild->get_icon(), 's').'</td><td><b>'.$guild->get_name().'</b></td></tr></table>';

}





?>
